package org.batatasframework.web;

import javax.servlet.ServletException;

import org.springframework.core.MethodParameter;

public class MissingLayoutVariableException extends ServletException{

	private static final long serialVersionUID = 813637775438762545L;

	private final String variableName;

	private final MethodParameter parameter;

	public MissingLayoutVariableException(String variableName, MethodParameter parameter) {
		super("");
		this.variableName = variableName;
		this.parameter = parameter;
	}

	@Override
	public String getMessage() {
		return "Missing layout variable '" + this.variableName +
				"' for method parameter of type " + this.parameter.getParameterType().getSimpleName();
	}

	/**
	 * Return the expected name of the path variable.
	 */
	public final String getVariableName() {
		return this.variableName;
	}

	/**
	 * Return the method parameter bound to the path variable.
	 */
	public final MethodParameter getParameter() {
		return this.parameter;
	}

}
